package com.huxi.http;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import org.springframework.http.client.SimpleClientHttpRequestFactory;

public class QuickClient extends Client {

	public QuickClient() {
		super(createRestTemplate(new SimpleClientHttpRequestFactory(), StandardCharsets.UTF_8));
	}

	public QuickClient(int connectTimeout, int readTimeout) {
		super(createRestTemplate(connectTimeout, readTimeout, StandardCharsets.UTF_8));
	}

	/**
	 * 重置HTTP客户端连接超时
	 * 
	 * @param connectTimeout 连接超时（毫秒）
	 * @param readTimeout    读取超时（毫秒）
	 * @param charset        响应字符编码
	 * @param 返回新的客户端
	 */
	public Client reset(int connectTimeout, int readTimeout, Charset charset) {
		if (charset == null) {
			charset = StandardCharsets.UTF_8;
		}
		return new Client(createRestTemplate(connectTimeout, readTimeout, charset));
	}

	/**
	 * 重置HTTP客户端连接超时
	 * 
	 * @param connectTimeout 连接超时（毫秒）
	 * @param readTimeout    读取超时（毫秒）
	 * @param 返回新的客户端
	 */
	public Client reset(int connectTimeout, int readTimeout) {
		return reset(connectTimeout, readTimeout, StandardCharsets.UTF_8);
	}
}
